﻿using MockDataAccess;
using MockDataTransferObject;
using System;
using System.Data;
using System.Collections.ObjectModel;

namespace MockBusiness
{
    public class ContractTypeBusiness
    {
        #region Initialize
        private static ContractTypeBusiness _instance;
        private readonly ContractTypeDataAccess _contractTypeDataAccess;

        /// <summary>
        /// Gets the contract type data test.
        /// </summary>
        public Collection<ContractType> ContractTypeDataTest
        {
            get
            {
                return _contractTypeDataAccess.AffectedRows;
            }
        }

        /// <summary>
        /// Prevents a default instance of the <see cref="ContractTypeBusiness"/> class from being created.
        /// </summary>
        private ContractTypeBusiness()
        {
            _contractTypeDataAccess = new ContractTypeDataAccess();
        }

        /// <summary>
        /// Prevents a default instance of the <see cref="ContractTypeBusiness"/> class from being created.
        /// </summary>
        /// <param name="isFake">if set to <c>true</c> [is fake].</param>
        private ContractTypeBusiness(bool isFake)
        {
            _contractTypeDataAccess = new ContractTypeDataAccess(isFake);
        }

        /// <summary>
        /// Retrieves the instance.
        /// </summary>
        /// <returns></returns>
        public static ContractTypeBusiness RetrieveInstance()
        {
            if (_instance == null)
                _instance = new ContractTypeBusiness();
            return _instance;
        }

        /// <summary>
        /// Retrieves the instance.
        /// </summary>
        /// <param name="isFake">if set to <c>true</c> [is fake].</param>
        /// <returns></returns>
        public static ContractTypeBusiness RetrieveInstance(bool isFake)
        {
            if (_instance == null)
                _instance = new ContractTypeBusiness(isFake);
            return _instance;
        }
        #endregion

        #region CUD
        #endregion

        #region R
        /// <summary>
        /// Retrieves the type of all contract.
        /// </summary>
        /// <returns></returns>
        public DataTable RetrieveAllContractType()
        {
            return _contractTypeDataAccess.RetrieveAllContractTypes();
        }

        /// <summary>
        /// Gets the name of the contract type id by contract type.
        /// </summary>
        /// <param name="contractTypeName">Name of the contract type.</param>
        /// <returns></returns>
        public object GetContractTypeIdByContractTypeName(string contractTypeName)
        {
            if (contractTypeName == null)
                return null;
            return _contractTypeDataAccess.GetContractTypeIdByContractTypeName(contractTypeName);
        }

        /// <summary>
        /// Gets the by id.
        /// </summary>
        /// <param name="contractTypeId">The contract type id.</param>
        /// <returns></returns>
        public ContractType GetById(object contractTypeId)
        {
            if (contractTypeId == null)
                return null;
            return _contractTypeDataAccess.GetById(contractTypeId);
        }
        #endregion
    }
}
